<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

        body {
            margin: 0;
            width: 100%;
            height: 100vh;
        }

        body div {
            float: left;
            outline: 1px solid red;
        }


    </style>
</head>
<body>

    <script>

        // 输入行列信息
        var str = prompt('输入行列信息'); // '2,3'
        var arr = str.split(','); // ['2', '3']
        var rowCount = +arr[0]; // 2
        var colCount = +arr[1]; // 3

        // 制作所有div 添加至父元素
        for (var i = 0; i < rowCount * colCount; i++) {
            var el = document.createElement('div');
            el.setAttribute('style', `
                width: ${ 100 / colCount }%;
                height: ${ 100 / rowCount }%;
            `);
            document.body.appendChild(el);
        }


    </script>
</body>
</html>